{% extends 'base.html' %}
{% load custom_tag %}

{% block title %}
    {{ block.super }} | 台网信息
{% endblock %}

{% block content %}
    <div class="d-flex justify-content-between flex-wrap flex-md-nowrap align-items-center pt-3 pb-2 mb-3 border-bottom">
        <h1 class="h2">台站信息</h1>
        <div class="btn-toolbar mb-2 mb-md-0">
            <div class="btn-group mr-2">
                <button class="btn btn-sm btn-outline-secondary">Share</button>
                <button class="btn btn-sm btn-outline-secondary">Export</button>
            </div>
            <button class="btn btn-sm btn-outline-secondary dropdown-toggle">
                <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none"
                     stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"
                     class="feather feather-calendar">
                    <rect x="3" y="4" width="18" height="18" rx="2" ry="2"></rect>
                    <line x1="16" y1="2" x2="16" y2="6"></line>
                    <line x1="8" y1="2" x2="8" y2="6"></line>
                    <line x1="3" y1="10" x2="21" y2="10"></line>
                </svg>
                This week
            </button>
        </div>
    </div>

    <nav aria-label="breadcrumb">
        <ol class="breadcrumb">
            <li class="breadcrumb-item"><a href="/">首页</a></li>
            <li class="breadcrumb-item active" aria-current="page">Library</li>
        </ol>
    </nav>

    <table class="table table-secondary">
        <thead>
        <tr>
            <th>台站代码</th>
            <th>台站名称(中文)</th>
            <th>台站名称(英文)</th>
            <th>台站经度</th>
            <th>台站纬度</th>
            <th>台站高程</th>
        </tr>
        </thead>
        <tbody>
        <tr>
            <td><a href="">{{ station.code }}</a></td>
            <td>{{ station.name_zh }}</td>
            <td>{{ station.name_en }}</td>
            <td>{{ station.longitude }}</td>
            <td>{{ station.latitude }}</td>
            <td>{{ station.altitude }}</td>
        </tr>
        </tbody>
    </table>
    {% if station.equipmentlist %}
        <h3>设备列表</h3>
        <ul class="list-group">
            <li class="list-group-item">
                <h4>测震设备</h4>
                <ul class="list-group">
                    {% for seismic in station.equipmentlist.seismic_equipment_entities.all %}
                        <li class="list-group-item">{{ seismic.model }}
                            <span class="btn btn-success">{{ seismic.sn }}</span></li>
                    {% endfor %}
                </ul>
            </li>
            <li class="list-group-item">
                <ul>
                    <h4>供电设备</h4>
                    {% for item in station.equipmentlist.equipmentitem_set.powersupply %}
                        <li>{{ item.content_object }} <span class="badge badge-secondary">{{ item.quantity }}</span>
                        </li>
                    {% endfor %}
                </ul>
                <ul>
                    <h4>通讯设备</h4>
                    {% for item in station.equipmentlist.equipmentitem_set.networkdevice %}
                        <li>{{ item.content_object }} <span class="badge badge-secondary">{{ item.quantity }}</span>
                        </li>
                    {% endfor %}
                </ul>

            </li>
            <hr/>
            <a class="btn btn-danger" href="{% url 'equipment:equipmentlist_edit' station_id=station.pk %}" role="button">更新设备列表</a>
        </ul>
    {% else %}
        <a class="btn btn-danger" href="{% url 'equipment:equipmentlist_add' station_id=station.pk  %}" role="button">添加设备列表</a>
    {% endif %}
{% endblock %}